Skip to content

Conversation

@antonpirker
Copy link
Contributor

@antonpirker antonpirker commented Sep 16, 2025

Description

When rendering templates of the Django Admin in Django 5.0+ the template context includes also a QuerySet with lots of log items.
In our serialize() function this was not properly serialized leading to evaluating the QuerySet (read: running the SQL query).

This change updates the serialize() to also correctly serialize QuerySets in span.data

Issues

@linear
Copy link

linear bot commented Sep 16, 2025

@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.56%. Comparing base (6c2a996) to head (42d15f9).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4804   +/-   ##
=======================================
  Coverage   84.56%   84.56%           
=======================================
  Files         158      158           
  Lines       16513    16521    +8     
  Branches     2866     2867    +1     
=======================================
+ Hits        13964    13971    +7     
  Misses       1703     1703           
- Partials      846      847    +1     
Files with missing lines Coverage Δ
sentry_sdk/serializer.py 97.84% <100.00%> (+0.09%) ⬆️

... and 1 file with indirect coverage changes

@antonpirker antonpirker marked this pull request as ready for review September 16, 2025 11:32
@antonpirker antonpirker requested a review from a team as a code owner September 16, 2025 11:32
cursor[bot]

This comment was marked as outdated.

@antonpirker antonpirker marked this pull request as draft September 16, 2025 11:35
@antonpirker antonpirker marked this pull request as ready for review September 16, 2025 12:05
@antonpirker antonpirker changed the title fix(Django): Avoid adding complex Django object to spans fix(Django): Avoid adding complex Django object to template spans Sep 16, 2025
Copy link
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a comment, ideally you can find the root cause.

Filtering the context is also fine with me, but the final representation cannot be misleading as currently implemented.

@antonpirker antonpirker changed the title fix(Django): Avoid adding complex Django object to template spans fix(Django): Avoid evaluating complex Django object when adding them to template spans Sep 17, 2025
@antonpirker antonpirker changed the title fix(Django): Avoid evaluating complex Django object when adding them to template spans fix(Django): Avoid evaluating complex Django object in span.data/span.attributes Sep 17, 2025
@antonpirker antonpirker merged commit 4329383 into master Sep 17, 2025
128 checks passed
@antonpirker antonpirker deleted the antonpirker/django5-admin-improvement branch September 17, 2025 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Huge performance impact in django wsgi mode after upgrading from django 4.2 to 5 and the sdk from 1.40 to 2.33

2 participants